function screahCustomerMessage(currentPage){
	var screah = $("#search").val();
	location.href="screahCustomerMessage.do?screah="+screah+"&currentPage="+currentPage;
}
//工人搜索
function screahWorkerMessage(currentPage){
	var screah = $("#search").val();
	location.href="screahWorkerMessage.do?screah="+screah+"&currentPage="+currentPage;
}
//经销商
function screahDealerMessage(currentPage){
	var screah = $("#search").val();
	location.href="screahDealerMessage.do?screah="+screah+"&currentPage="+currentPage;
}
//供货商
function screahSupplierMessage(currentPage){
	var screah = $("#search").val();
	location.href="screahSupplierMessage.do?screah="+screah+"&currentPage="+currentPage;
}
//商家
function screahBusinessMessage(currentPage){
	var screah = $("#search").val();
	location.href="screahBusinessMessage.do?screah="+screah+"&currentPage="+currentPage;
}
//工厂
function screahFactoryMessage(currentPage){
	var screah = $("#search").val();
	location.href="screahFactoryMessage.do?screah="+screah+"&currentPage="+currentPage;
}
//增加新消息
function addMessage(){
	$.post(
			"../message/addMessage.do",
			$("#addMessageII").serialize(),
			function(data){
				if(data==1){
					success("恭喜您, 消息增加成功!");
					setTimeout(myfresh,1000);
				}else if(data==0){
					fail("对不起,消息增加未成功!原因:数据库异常或者你没有修改数据!!");
				}
			}
	);
}
//删除消息
function toDeleteMessage(messageId){
	$.post(
			"../message/toDeleteMessage.do?messageId="+messageId,
			function(data){
				if(data==1){
					setTimeout(myfresh,10);
				}else if(data==0){
					fail("对不起,消息增加未成功!原因:数据库异常或者你没有修改数据!!");
				}
			}
	);
}
//点击消息,显示和修改
function clickMessage(messageId){
	$("input[name='optionsRadios']").removeProp("checked");
	$.post("../message/toUpdateMessage.do?messageId="+messageId,
			function(data){
				$("#messageName>div>input").val(data.content);
				$("#messageId").val(data.messageId);
				if(data.status==1){
					$("#openStatus").attr({checked:"checked"});
				}else{
					$("#closeStatus").attr({checked:"checked"});
				}
				if(data.type==2){
					$("#type1").attr({checked:"checked"});
				}else if(data.type==4){
					$("#type2").attr({checked:"checked"});
				}else if(data.type==7){
					$("#type3").attr({checked:"checked"});
				}
			
			},
			'json'
	);
}
//保存活动
function saveMessage(){	
	$.post(
			"../message/updateMessage.do",
			$("#messageX").serialize(),
			function(data){
				if(data==1){
					success("恭喜您, 修改成功!");
					 setTimeout(myfresh,1000);
				}else if(data==0){
					fail("对不起,修改未成功!原因:数据库异常或者你没有修改数据!!");
					setTimeout(myfresh,1000);
				}
			}
	);
}
//操作成功之后提示
function success(text){
	  $("#alerts").html("<div  style='text-align: center; display:no;' class='alert alert-success alert-dismissable'><strong>"+text+"</strong></div>");
	  $("#menus").click();

}
function myfresh(){
	window.location.href=window.location.href;
}